home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #2 / Amiga Plus CD - 1999 - No. 2.iso / System-Boost / Grafik / MetaView / ARexx-Examples / PageStream_Import.rexx < prev    next >
OS/2 REXX Batch file  |  1998-11-08  |  2KB  |  122 lines

  1. /* Graphik Import in PageStream3 mittels MetaView */
  2.  
  3. call open("STDERR","ram:tracePSG","W")
  4. trace r
  5.  
  6. METAVIEW = 'MetaView:MetaView'    /* Please complete the path */
  7.  
  8. OPTIONS RESULTS
  9. SIGNAL ON FAILURE
  10. SIGNAL ON SYNTAX
  11.  
  12. /*
  13. ** Looking for our start process
  14. */
  15.  
  16. PGSPORT = ADDRESS()
  17. if (LEFT(PGSPORT, 10) ~= "PAGESTREAM") then do /* not started from DrawStudio */
  18.     say "Please start me from PageStream!"
  19.     EXIT
  20. end
  21.  
  22.  
  23. /*
  24. ** Create a new Metaview process:
  25. ** first look for the allready running processes
  26. ** then the new Port will be the next one
  27. */
  28.  
  29. do NUMBER = 0 to 20
  30.     if (SHOW(PORTS,"METAVIEW." || NUMBER) = 0) then
  31.     leave
  32. end
  33.  
  34. /*
  35. ** Searching for MetaView: 1. our path above,
  36. **    2. path in env:MetaView.path
  37. ** or 3. you must have a assign "MetaView:"
  38. */
  39.  
  40. if (EXISTS(METAVIEW)=0) then do
  41.     if OPEN("MVVAR","env:MetaView.path","Read") then do
  42.         METAVIEW = READLN("MVVAR")
  43.     end
  44.     if (EXISTS(METAVIEW)=0) then do
  45.         METAVIEW = "MetaView:MetaView"
  46.     end
  47. end
  48.  
  49. /*
  50. ** Enable warnings for WaitForPort
  51. */
  52.  
  53. OPTIONS FAILAT 5
  54. ADDRESS COMMAND
  55.     "run " || METAVIEW || " NODISPLAY"
  56.     MVPORT = "METAVIEW." || NUMBER
  57.     "WaitForPort " || MVPORT
  58.  
  59. /*
  60. ** Ignore the other errors
  61. */
  62.  
  63. OPTIONS FAILAT 21
  64.  
  65. defilename = getclip(metafilename)
  66. depathname = getclip(metapathname)
  67.  
  68. ADDRESS PAGESTREAM
  69. if defilename = "" then GETFILE TITLE "Select drawing"  LOAD POSBUTTON Load NEGBUTTON Cancel
  70.  
  71. else GETFILE TITLE "Select drawing" LOAD PATH depathname FILE defilename POSBUTTON Load NEGBUTTON Cancel
  72. if rc=10 then EXIT
  73. filename = result
  74.  
  75. call setclip(metafilename, getname(filename))
  76. call setclip(metapathname, getpath(filename))
  77.  
  78. /*
  79. ** Do all needed things with MetaView (LOAD,SAVE,QUIT...)
  80. */
  81.  
  82. ADDRESS VALUE MVPORT
  83.     LOAD '"'filename'"'
  84.     SAVE "t:test.dr2d" AS DR2D
  85.     QUIT
  86.  
  87. /*
  88. **  Import the temporary file in application
  89. */
  90.  
  91.  
  92. ADDRESS 'PAGESTREAM'
  93. 'PLACEGRAPHIC FILE t:test.dr2d FILTER IFFDR2D STATUS'
  94.  
  95. EXIT
  96.  
  97. FAILURE:
  98.     ADDRESS COMMAND
  99.     REQUESTCHOICE "Error" """Can't find" METAVIEW "!""" "OK"
  100.     EXIT
  101.  
  102. SYNTAX:
  103.     say "Error on line" SIGL ":" ERRORTEXT(RC) "!"
  104.     EXIT
  105.  
  106.  
  107.  
  108. getpath:
  109. parse arg allname
  110. pos1 = lastpos("/",allname)
  111. if pos1 = 0 then pos1 = lastpos(":",allname)
  112. filepath = left(allname,pos1)
  113. return filepath
  114.  
  115. getname:
  116. parse arg allname
  117. pos1 = lastpos("/",allname)
  118. if pos1 = 0 then pos1 = lastpos(":",allname)
  119. justname = substr(allname,pos1+1)
  120. return justname 
  121.  
  122.